//MyToString.java
package com.xyc.ch6;
class Cat						//CatÀàÃ»ÓÐ¸²¸ÇtoString·½·¨
{
	private int catNo;
	Cat(int n)
	{
		catNo=n;
	}
}
class Dog						//DogÀà¸²¸ÇÁËtoString·½·¨
{
	private int dogNo;
	Dog(int n)
	{
		dogNo=n;
	}
	public String toString()
	{
		return ""+dogNo;
	}
}

public class MyToString
{
	public static void main(String[] args)
	{
		Cat c=new Cat(1);
		System.out.println(c.toString());	//ÏÔÊ½µ÷ÓÃtoString·½·¨
		System.out.println(c);				//×Ô¶¯µ÷ÓÃtoString·½·¨

		Dog d=new Dog(1);
		System.out.println(d.toString());	//ÏÔÊ½µ÷ÓÃtoString·½·¨
		System.out.println(d);				//×Ô¶¯µ÷ÓÃtoString·½·¨
		System.out.println("Dog No."+d);	//×Ô¶¯µ÷ÓÃtoString·½·¨
   }
}